import logging
import redis


class Config(object):
    SQLALCHEMY_DATABASE_URI = 'mysql://root:mysql@localhost/fenre'
    SQLALCHEMY_TRACK_MODIFICATIONS = True
    #在强求结束之前自动提交数据库的修改
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True
    # redis配置信息
    HOST = '127.0.0.1'
    PORT = 6379
    #
    # 4.0生成随机数
    # SECRET_KEY = '1egY3wXpn8FO/cUlP+s+aBB1D1Ct38sqrGdHDAFmUG1qELJzXxu5d4zZTvxAbj1L/0Hw7EJVUxgmvNy/oYs='
    SECRET_KEY = 'asTFeAXtNhXNii7kwWzNlH/W7G84rHYC8YEeAAo0eJo='
    # 4.2配置flask-session扩展
    SESSION_TYPE = 'redis'  # 设置同步信息
    SESSION_REDIS = redis.StrictRedis(port=PORT,host=HOST)
    SESSION_USE_SIGNER = True  # 开启签名,保证数据安全
    PERMANENT_SESSION_LIFETIME = 86400 * 7  # 配置国企时间


class DevelopementConfig(Config):
    """开发模式下的配置"""
    DEBUG = True
    LOG_LEVEL = logging.DEBUG


class ProductionConfig(Config):
    """生产模式下的配置"""
    DEBUG = False
    LOG_LEVEL = logging.WARNING